<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>component-4 component标签</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>component-4 component标签</h1>
    <hr/>
    <div id="app">
        <!--这里动态绑定使用的组件-->
        <component :is='who'></component>
    </div>

    <script>

        var componentA = {
            template: `
                <div style="color:red">I'm componentA</div>
            `
        };
        var componentB = {
            template: `
                <div style="color:green">I'm componentB</div>
            `
        };
        var componentC = {
            template: `
                <div style="color:blue">I'm componentC</div>
            `
        };

        var app = new Vue({
            el: '#app',
            data: {
                who: 'componentC'
            },
            //注册组件
            components: {
                componentA: componentA,
                componentB: componentB,
                componentC: componentC,
            }
        });
    </script>

</body>
</html>